import time

from jiaqizuoye.zuoye2.Base import Base
from selenium.webdriver.common.by import By
from selenium import webdriver
class Page(Base):
    denglu_loc=(By.XPATH,'/html/body/div[2]/div/div[1]/div/a[1]')
    def denglu(self):
        self.click(self.denglu_loc)
    name_loc=(By.ID,'userName')
    def name(self):
        self.send_keys(self.name_loc,'15336710135')
    password_loc=(By.NAME,'_pwd')
    def password(self):
        self.send_keys(self.password_loc,'002816Hj')
    dengluanniu_loc=(By.XPATH,'//*[@id="save"]')
    def dengluanniu(self):
        self.click(self.dengluanniu_loc)
    qved=(By.CSS_SELECTOR,'.bindSub')
    def qd(self):
        self.click(self.qved)
    ssk_loc=(By.CLASS_NAME,'search-form')
    def ssk(self):
        self.send_keys(self.ssk_loc,'茅台')
    def test_jiuxian(self):
        try:
            self.goto('https://www.jiuxian.com/')
            time.sleep(2)
            self.denglu()
            self.name()
            self.password()
            time.sleep(10)
            self.dengluanniu()
            self.driver.implicitly_wait(5)
            self.qd()
            time.sleep(2)
            self.ssk()
        except Exception as e:
            times=time.strftime('%Y%m%d_%H%M%S',time.localtime())
            self.driver.save_screenshot('hj'+times+'.png')